import { Column, CreateDateColumn, Entity, PrimaryGeneratedColumn } from 'typeorm';

@Entity('logs')
export class Log {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ nullable: true })
  userId: number;

  @Column({ nullable: true })
  username: string;

  @Column()
  method: string;

  @Column()
  url: string;

  @Column({ nullable: true })
  ip: string;

  @Column({ nullable: true })
  userAgent: string;
  
  @Column({ nullable: true })
  browser?:string;

  @Column({ type: 'text', nullable: true })
  requestBody: string;

  @Column({ type: 'text', nullable: true })
  queryParams: string;

  @Column({ type: 'longtext', nullable: true })
  responseBody: string;

  @Column({ nullable: true })
  statusCode: number;

  @Column({ nullable: true })
  responseTime: number;

  @Column({ nullable: true })
  errorMessage: string;

  @Column({ default: 'info' })
  level: string;

  @Column({ nullable: true })
  module: string;

  @Column({ nullable: true })
  action: string;

  @CreateDateColumn()
  createdAt: Date;
}
